package com.miniot.base.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miniot.base.dto.WarehouseManageDTO;
import com.miniot.base.entity.BoundManage;
import com.miniot.base.entity.WarehouseManage;
import com.miniot.base.mapper.WarehouseManageMapper;
import com.miniot.base.service.BoundManageService;
import com.miniot.base.service.TypeTwoService;
import com.miniot.base.service.WarehouseManageService;
import com.miniot.base.vo.CountVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 仓库表
 *
 * @author zzq
 * @date 2023-10-17 11:15:34
 */
@Service
@AllArgsConstructor
@Slf4j
public class WarehouseManageServiceImpl extends ServiceImpl<WarehouseManageMapper, WarehouseManage> implements WarehouseManageService {

    private BoundManageService boundManageService;
    private TypeTwoService typeTwoService;
    @Override
    public boolean removeWarehouseManageById(Long id) {
        if (ObjectUtil.isEmpty(id)) {
            throw new RuntimeException("id不能为空");
        }
        List<BoundManage> list = boundManageService.list(new LambdaQueryWrapper<BoundManage>().eq(BoundManage::getWarehouseId, id));
        if (list.size()>0) {
            throw new RuntimeException("改投入品正在使用,不能删除");
        }
        this.removeById(id);
        return true;
    }


}
